// Package tools 开发工具包
package tools

import (
    "time"
    "unsafe"
)

// BytesToString 字节转字符串
func BytesToString(data []byte) string {
    return *(*string)(unsafe.Pointer(&data))
}

// StringToBytes 字符串转字节数组
func StringToBytes(data string) []byte {
    return *(*[]byte)(unsafe.Pointer(&data))
}

// SetInterval 自定义，定时器工具
func SetInterval(ms time.Duration, f func()) {
    tick := time.Tick(ms)
    for {
        select {
        case <-tick:
            f()
        }
    }
}
